package com.es.designmode.composite;

import cn.hutool.core.util.StrUtil;

/**
 * 定义叶节点对象，叶节点没有子节点
 *
 * @author Will
 */
public class Leaf extends Component {

    public Leaf(String name) {
        super(name);
    }

    @Override
    public void add(Component c) {
        System.out.println("Cannot add to a leaf");
    }

    @Override
    public void remove(Component c) {
        System.out.println("Cannot remove from a leaf");
    }

    @Override
    public void display(int depth) {
        System.out.println(StrUtil.repeat('-', depth) + getName());
    }
}
